<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

    $username = $_POST["username"];
    $password = $_POST["password"];
    $firstName = $_POST["firstName"];
    $lastName = $_POST["lastName"];
    $year = $_POST["year"];
    $month = $_POST["month"];
    $day = $_POST["day"];
    $userType = $_POST["userType"];
    
    $con = mysql_connect("localhost", "zhouzhao", "19831022");
        
    if(!$con){
        die("could NOT connect to DB".mysql_error());
    }else{
//        echo "DB is connected<br/>";
    }

    mysql_select_db("cloudcom", $con);

    if(!mysql_query("insert into users values
            (null, '$username', '$password', '$firstName', '$lastName', '$year-$month-$day', '$userType')")){
        die("error: ".mysql_errno());
    }else{
        echo "New employee $firstName $lastName has been registered<br/>";
        require 'login.html';
    }

    mysql_close($con);
    
?>
